package cn.dc406.labc406mgr.mapper;
import cn.dc406.labc406mgr.entity.Lenddetails;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;


@Mapper
public interface LenddetailsWapper {
    @Select("select * from lenddetails")
    List<Lenddetails> selectALLlend();

    @Select("select * from lenddetails where state='1'")
    List<Lenddetails> selectApplication();

    @Select("select * from lenddetails where state='1' and username=#{username}")
    List<Lenddetails> selectApplicationByUsername(String username);

    @Update("update lenddetails set username=#{username},itemid=#{itemid},num=#{num},applytime=#{applytime},lendtime=#{lendtime},returntime=#{returntime},state=#{state} where id=#{id}")
    Boolean Updatelend(Lenddetails lenddetails);

    @Update("update lenddetails set state='2',lendtime=CURRENT_TIMESTAMP where id=#{id}")
    Boolean accessApplication(Integer id);

    @Select("select * from lenddetails where username=#{username}")
    List<Lenddetails> selectlendByUsername(String username);


    @Delete("delete from lenddetails where id=#{di}")
    Boolean deletelendByID(int id);

}
